<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta name="description" content="">
		<meta name="author" content="Mosaddek">
		<meta name="keyword" content="FlatLab, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
		<link rel="shortcut icon" href="img/favicon.html">

		<title>新增车辆变更</title>

		<!-- Bootstrap core CSS -->
		<link href="css/bootstrap.min.css" rel="stylesheet">
		<link href="css/bootstrap-reset.css" rel="stylesheet">
		<!--external css-->
		<link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
		<!-- Custom styles for this template -->
		<link href="css/style.css" rel="stylesheet">
		<link href="css/style-responsive.css" rel="stylesheet" />

		<!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
		<!--[if lt IE 9]>
      <script src="js/html5shiv.js"></script>
      <script src="js/respond.min.js"></script>
    <![endif]-->
	</head>

	<body>

		<!--main content start-->
		<section id="main-content">
			<section class="wrapper">
				<div class="row">
					<div class="col-sm-12">
						<section class="panel">
							<!-- <div class="bio-graph-heading">
                              新增车辆变更
                          </div> -->
							<div class="panel-body bio-graph-info">

								<form class="form-horizontal" role="form">
									<div class="form-group">
										<label class="col-lg-1 control-label">车牌号：</label>
										<div class="col-lg-5">
											<input type="text" class="form-control" id="carNumber" placeholder=" ">
										</div>

										<label class="col-lg-1 control-label">车主id：</label>
										<div class="col-lg-5">
											<input type="text" class="form-control" id="carOwner" placeholder=" ">
											</select>
										</div>
									</div>

									<div class="form-group">
										<label class="col-lg-1 control-label">现车主：</label>
										<div class="col-lg-5">
											<input type="text" class="form-control" id="carOwnerNow" placeholder=" ">
										</div>

										<label class="col-lg-1 control-label">转让费：</label>
										<div class="col-lg-5">
											<input type="text" class="form-control" id="transfer_fee" placeholder=" ">
										</div>
									</div>
									<div class="form-group">
										<label class="col-lg-1 control-label">转让时间：</label>
										<div class="col-lg-5">
											<input type="text" class="form-control" id="transfer_time" placeholder=" " onclick="jeDate({dateCell:'#transfer_time',isTime:true,format:'YYYY-MM-DD hh:mm:ss'})"/>
										</div>

										<label class="col-lg-1 control-label">行车证号：</label>
										<div class="col-lg-5">
											<input type="text" class="form-control" id="drivingLicenseNo" placeholder=" ">
										</div>
									</div>
									<div class="form-group">
										<label class="col-lg-1 control-label">燃油类型：</label>
										<div class="col-lg-5">
											<select size="1" name="sample_1_length" aria-controls="sample_1" class="form-control" id="fuelType">
												<option value="全部" selected="selected">全部</option>
												<option value="汽油90号">汽油90号</option>
												<option value="柴油">柴油</option>
												<option value="汽油97号">汽油97号</option>
											</select>
										</div>

										<label class="col-lg-1 control-label">座位数：</label>
										<div class="col-lg-5">
											<input type="text" class="form-control" id="seating" placeholder=" ">
										</div>
									</div>

									<div class="form-group">
										<label class="col-lg-1 control-label">车身状况：</label>
										<div class="col-lg-5">
											<input type="text" class="form-control" id="bodyCondition" placeholder=" ">
										</div>

										<label class="col-lg-1 control-label">车辆颜色：</label>
										<div class="col-lg-5">
											<select size="1" name="sample_1_length" aria-controls="sample_1" class="form-control" id="color">
												<option value="全部" selected="selected">全部</option>
												<option value="红色">红色</option>
												<option value="银色">银色</option>
												<option value="白色">白色</option>
											</select>
										</div>
									</div>
									<div class="form-group">
										<label class="col-lg-1 control-label">登记时间：</label>
										<div class="col-lg-5">
											<input type="text" class="form-control" id="boardingTime" placeholder=" " onclick="jeDate({dateCell:'#boardingTime',isTime:true,format:'YYYY-MM-DD hh:mm:ss'})"/>
										</div>

									</div>

									<div class="form-group">
										<label class="col-lg-1 control-label">备注：</label>
										<div class="col-lg-5">
											<textarea name="" id="remark" class="form-control" cols="10" rows="5"></textarea>
										</div>

										<label class="col-lg-1 control-label">车辆图片：</label>
										<div class="col-lg-5">
											<input type='text' id='textfield' class='form-control' />
											<input type="file" class="file-pos" id="exampleInputFile" multiple="multiple">
										</div>
										<!-- <label  class="col-lg-1 control-label">车尾</label>
                                    <div class="col-lg-5">
                                        <input type="file" class="file-pos" id="exampleInputFile">
                                    </div>
                                    <label  class="col-lg-1 control-label">车身</label>
                                    <div class="col-lg-5">
                                        <input type="file" class="file-pos" id="exampleInputFile">
                                    </div> -->

										<div class="col-lg-2">

										</div>
									</div>
									<div class="form-group">

										<div class="col-lg-6">
											<button class="btn btn-shadow btn-primary" onclick="buttons();return false;">确认</button>
										</div>
										
										<div class="col-lg-6">
											<button type="reset" class="btn btn-shadow btn-default">取消</button>
										</div>
										
									</div>

								</form>
							</div>
						</section>
					</div>
				</div>

			</section>
		</section>
		<!--main content end-->
		</section>

		<!-- js placed at the end of the document so the pages load faster -->
		<script src="js/jquery.js"></script>
		<script src="js/bootstrap.min.js"></script>
		<script src="js/jquery.scrollTo.min.js"></script>
		<script src="js/jquery.nicescroll.js" type="text/javascript"></script>
		<script src="js/jedate/jedate.js"></script>

		<!--common script for all pages-->
		<script src="js/common-scripts.js"></script>

		<!--script for this page only-->
		<script src="js/dynamic-table.js"></script>
		<script src="js/json2.js"></script>
		<script type="text/javascript">
			function buttons() {
				var carNumber = $('#carNumber').val(),
					carOwnerId = $('#carOwner').val(),
					carOwnerNow = $('#carOwnerNow').val(),
					transfer_fee = $('#transfer_fee').val(),
					transfer_time = $('#transfer_time').val(),
					drivingLicenseNo = $('#drivingLicenseNo').val(),
					fuelType = $('#fuelType').val(),
					seating = $('#seating').val(),
					bodyCondition = $('#bodyCondition').val(),
					color = $('#color').val(),
					boardingTime = $('#boardingTime').val(),
					remark = $('#remark').val(),
					url = $('#textfield').val();

				var datalist = {
					carId: carNumber,
					old_user_id: carOwnerId,
				    new_user_id: carOwnerNow,
					transfer_fee: transfer_fee,
					transfer_time: transfer_time,
					drive_number: drivingLicenseNo,
					fuel_type: fuelType,
					seat_count: seating,
					car_state: bodyCondition,
					car_color: color,
					create_time: boardingTime,
					comment: remark,
					pic_urls: url
				};
				var t = JSON.stringify(datalist);
				$.ajax({
					url: 'cartransfer_insert.action',
					type: 'POST',
					dataType: 'json',
					data: "data=" + t,

					success: function(data) {
						alert(data.data);
						console.log('success');
					},

					error: function(data) {
						alert(data.data);
					}

				})
			}

			//获取真实上传路径
			function getObjectURL(file) {
				var url = null;
				if(window.createObjectURL != undefined) { // basic
					url = window.createObjectURL(file);
				} else if(window.URL != undefined) { // mozilla(firefox)
					url = window.URL.createObjectURL(file);
				} else if(window.webkitURL != undefined) { // webkit or chrome
					url = window.webkitURL.createObjectURL(file);
				}
				return url;
			}
			$("#exampleInputFile").change(function() {
				var objUrl = getObjectURL(this.files[0]);　　
				console.log("objUrl = " + objUrl);　　
				if(objUrl) {　　　
					$("#textfield").attr("value", objUrl);
				}
			});
		</script>
	</body>

</html>